<template>
  <div class="main-plan-list">
        <div class="container" >
            <div class="plan-list" v-if="plan_list.length !== 0">
                <div class="plan-cell" v-for="cell in plan_list" :key="cell.id" >
                    <div class="plan-title">
                        <span class="execute-date-tips">执行日期</span>
                        <span v-html="cell.executeDate" class="execute-date"></span>
                    </div>
                    <div class="status">
                        <i class="status-icon"></i>
                        <span class="status-label" :class="'status-'+cell.taskStatus" v-html="status[cell.taskStatus]"></span>
                    </div>
                    <div class="plan-detail">
                        <div class="real-sum">
                            <span>￥<span class="plan-real-amount text-overflow" v-html="cell.amount.toFixed(2)"></span></span>
                            <span class="plan-label" v-html="cell.taskType === 1? '本次消费金额':'本次提现金额'" ></span>
                        </div>
                        <div class="plan-sum">
                            <span>￥<span class="plan-amount text-overflow" v-html="cell.realAmount.toFixed(2)"></span></span>
                            <span class="plan-label">还款总金额</span>
                        </div>
                    </div>
                    <div class="plan-detail">
                        <div class="plan-sum">
                            <span>￥<span class="plan-amount text-overflow" v-html="cell.serviceCharge.toFixed(2)"></span></span>
                            <span class="plan-label">服务费</span>
                        </div>
                        <div class="real-sum">
                            <span>￥<span class="plan-real-amount text-overflow" v-html="cell.totalServiceCharge.toFixed(2)"></span></span>
                            <span class="plan-label">应收服务费</span>
                        </div>
                    </div>
                </div> 
            </div>
            <div class="no-container" v-else>
                    没有数据
            </div>   
        </div>
  </div>
</template>

<script>
    
export default {
  name:'main-plan-list',
  data () {
    return {
        cardNo:null,
        userId:null,
        status:["待执行","成功","等待","执行中","异常"],
        plan_list:[],
    };
  },
  created() {
      this.init()
  },
  mounted() {},
  methods: {
      init(){
           this.cardNo = this.$route.params.cardNo;
           this.userId = sessionStorage.getItem('userid');
           this.getMainPlanList();
      },
      getMainPlanList(){
          this.$vux.loading.show();
          let url = "creditcardmanager/query/taskbill/all/batchno",
              params =encodeURI(`type=1&userId=${this.userId}&creditCardNumber=${this.cardNo}`); 
         this.$Http.post(url,params).then((res)=>{
             this.$vux.loading.hide()
              if(res.data.resp_code === "000000"){
                  try {
                     this.plan_list = res.data.result.page.content; 
                  } catch (error) {
                      this.plan_list = []
                  }
                  
              }else{
                  this.$vux.alert.show({
                      title:'温馨提示',
                      content:res.data.resp_message
                  })
              }          
          }).catch((err)=>{
              this.$vux.loading.hide()
            //   console.log("请求失败",err)
            this.$vux.alert.show({
                title:'温馨提示',
                content:"请求主计划列表失败！"
            })
          })
     },
  }
}

</script>
<style scoped>
.main-plan-list,.container{
    width: 100%;
    height: 100%;
    box-sizing: border-box;
    overflow: hidden;
}
.container{
    overflow-y: auto;
}
.plan-cell{
    padding: 0.75rem 0 1.6875rem 1.25rem;
    background-color: #ffffff;
    margin-top: 0.625rem;
}
.plan-title{
    position: relative;
    width: 100%;
    box-sizing: border-box;
    padding-right: 1.25rem;
    padding-bottom: 0.625rem;
    border-bottom: 1px solid #ededed;
}
.execute-date{
    display: inline-block;
    height: 1.25rem;
    line-height: 1.25rem;
    font-size: 0.875rem;
    vertical-align: middle;
    color:#aaaaaa;
    padding-left: 0.875rem;
}
.execute-date-tips{
    display: inline-block;
    height: 1.5rem;
    line-height: 1.5rem;
    font-size:1.0625rem; 
    vertical-align: middle;
}
.status{
    padding-top: 0.8125rem;
    padding-bottom: 1.5rem;
    font-size: 0.875rem;
    line-height: 1.5rem;
}
.status-label{
    display: inline-block;
    height:1.5rem ;
}
.plan-detail{
    width: 100%;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    box-sizing: border-box;
    padding-right: 2.5rem;
    text-align: center;
}
.plan-sum,.real-sum{
   width: 50%;
   display: flex;
   flex-direction: column;
   justify-content: space-between;
   align-items: stretch;
   font-size: .8rem;
   color:#626262;
   padding-bottom: 0.25rem;
}
.plan-amount,.plan-real-amount{
    font-size: 1.5rem;   
}
.plan-label{
    display: inline-block;
    height: 1rem;
    line-height: 1rem;
    font-size: 0.75rem;
    color:#aaaaaa;
}
.no-detail-list,.no-container{
    text-align: center;
    padding-top: 2rem;
    color:#626262;
    width: 100%;
    height: 100%;
    background-color: #ffffff;
    opacity: 0.6;
}

.task-type{
    height:2.8125rem;
    width: 2.8125rem;
    background-color: #40d7ff;
    background-position: center;
    background-repeat: no-repeat;
    background-size: 100%;
}
.task-detail{
    flex-grow: 1;
    box-sizing: border-box;
    padding-left: 1rem;
    font-size: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: stretch;
    color:#626262;
}
.detail-left,.detail-right{
    display: flex;
     flex-grow: 1;
    flex-direction: column;
    justify-content: space-between;
    align-items: stretch;
    box-sizing: border-box;
    padding: 0.25rem;
    box-sizing: border-box;
}
.detail-right{
    text-align: right;
}
.detail-executeDateTime{
    font-size: 0.9375rem;
}
.detail-realAmount{
    font-size: 1.1875rem;
}
.detail-taskStatus{
    color:#4a90e2;
}
.task-type-1{
    background-image: url(../../../static/img/amount.png);
    
}
.task-type-2{
    background-image: url(../../../static/img/repay.png);
}
/**/
.status-0{
    color: #cccccc; 
}
.status-1{
    color:#71e9a4; 
}
.status-2{
    color: #40d7ff;
}
.status-3{
    color: #ffd14b;
}
.status-4{
    color: #f16541;
}
</style>